package com.ding.easycontroller.dao.impl;

import com.ding.easycontroller.dao.ServiceDao;
import com.ding.easycontroller.file.ServiceFile;
import com.ding.easycontroller.work.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 脚本持有者
 */

@Repository
public class ServiceDaoImpl implements ServiceDao {


    //与文件系统保持一致性

    @Autowired
    private ServiceFile serviceFile;

    public List<Service> listAll() {
        return serviceFile.listAll();
    }

    synchronized
    public void add(Service service) {
        serviceFile.add(service);
    }

    synchronized
    public void removeById(String id) {
        serviceFile.removeById(id);
    }

    @Override
    public void update(Service service) {
        serviceFile.update(service);
    }

}
